Music Object Extension - Ducking

  Contents

About This Extension

What is Ducking?

The term "ducking", as it is used in the radio broadcasting profession, refers to the technique of reducing the volume level of the primary audio content so that an announcer can interject commentary and be heard clearly. Typically, the primary audio content continues while the announcer is speaking in order to create a smoother and less jarring experience. This technique also has the convenience of not requiring that it be possible to pause the primary audio content - particularly useful in live broadcasting situations.

A Burden Lifted

In the broadcasting profession, ducking is typically implemented in an automatic manner using specialized audio processing hardware, so as to take the burden of managing audio levels off the announcer. In the same way that such audio hardware takes the burden off the announcer, so the Ducking extension takes the burden off developers of sonified content.

The Ducking extension provides methods for linking instances to one another and setting up automated ducking relationships. If you were to hand code these behaviors into each sonification project, a good deal of time would be spent with this rather mundane and mechanical aspect of the sonification, instead of being able to spend more time on the creative aspects. The Ducking extension lifts a major burden from you and lets you get down to the stuff that really counts - exercizing the skills of sound design, musical composition, and interactive audio conceptualization.

Benefits of Ducking in Sonification

Masters & Slaves

Ducking is, in essence, a master-slave relationship. If a Music Object instance is configured in a ducking relationship as a slave, then that instance will be ducked while its master is audible. When the ducking master becomes audible, it issues an "order" to the slave. The slave, in turn, does its master's bidding by "obeying" this order to reduce its volume. When the master becomes inaudible once again, it "grants" permission to its slave to restore its original volume level so that it may once again be fully heard. So, a ducking slave is affected during a ducking process while a ducking master is not.

The Ducking extension is very flexible and allows a ducking slave to have multiple ducking masters, and also allows a ducking master to have multiple ducking slaves (see the section Complex Ducking Relationships).

Ducking, Volume, and Volume Scalars

Because ducking is, by definition, a process that affects volume, a sensible way had to be found to achieve the desired volume attenuation. One possible approach would be to use a Music Object instance's main volume setting, that can be set using the VOLUME embedding property or the setVolume instance method). However, because this main volume setting is often used to balance out the mix of various sonification elements in a page, using this setting could be quite obstructive to developing sonified content, since ducking processes would overwrite this volume setting and possibly even "fight" with other code for control over it.

Instead, the Ducking extension uses the system of custom volume scalars (see the section Important Concepts: Custom Volume Scalars) in order to achieve the desired volume attenuation in a way that respects a Music Object instance's main volume setting. When the Ducking extension is used, a dedicated volume scalar is assigned to each Music Object for the purpose of ducking. A single volume scalar is assigned to a Music Object instance, regardless of how many ducking masters the instance may have. If an instance has multiple ducking masters that are audible, then the multiple concurrent ducking tasks for that instance will cooperate with each other in setting the level of the instance's ducking volume scalar (see the section Multiple Concurrent Ducking).

IMPORTANT

The Ducking extension assigns a dedicated volume scalar named "[R]ducking" to each Music Object instance. If you are creating your own custom volume scalars, you should never choose names that begin with the text "[R]", since this prefix is used by the Music Object API for its own reserved volume scalars (see the section Custom Volume Scalars: Reserved Volume Scalars).

Anatomy of a Simple Ducking Process

For a simple ducking relationship where one Music Object instance has only one ducking master, a ducking process is triggered for the instance when the instance's ducking master becomes audible, and this ducking process is then released when the ducking master once again becomes inaudible.

While ducking is in progress, the level of the slave instance's dedicated ducking volume scalar is faded appropriately in order to achieve the desired pattern of volume attenuation for the instance. The following diagram illustrates a simple ducking process by contrasting elapsed time (on the X axis) against the value of the ducking volume scalar (on the Y axis). The timeline is divided up into discrete sections, indicating the different phases that make up a simple ducking process. These phases are described in more detail below the illustration.

Ducking - Diagram 1

Complex Ducking Relationships

The Ducking extension is very flexible and allows a ducking slave to have multiple ducking masters, and also allows a ducking master to have multiple ducking slaves.

For a complex ducking relationship where one Music Object instance has multiple ducking masters, a ducking process is triggered for the instance when one or more of the instance's ducking masters become audible, after all the ducking masters were previously inaudible. A ducking process for the instance is effectively only released when all of the instance's ducking masters become inaudible, after some of the ducking masters were previously audible.

Multiple Concurrent Ducking

With the Ducking extension it is possible for one ducking slave to have multiple ducking masters. It is, therefore, possible for a slave to be ducked by more than one master at the same time. In such cases, the Ducking extension must resolve multiple separate requests to control the value of the slave's ducking volume scalar. In order to do this, the Ducking extension uses the following two rules...

What these two rules amount to, essentially, is the melding together of all envelopes for concurrent ducking tasks into one envelope, by always taking the minimum value out of all active ducking tasks at any point in time.

The following diagram illustrates how the Ducking extension handles concurrent ducking tasks, and how the value of the ducking volume scalar is derived from these ducking tasks. In order to keep things fairly simple, this diagram only shows the combination of two ducking tasks, but these very same principles can be applied to any number of concurrent ducking tasks. The two ducking tasks shown are triggered at different times, released at different times, and have different settings for attack time, sustain level, and release time.

Ducking - Diagram 2

In the diagram, the green lines and annotations indicate ducking task A, while the blue lines and annotations indicate ducking task B. The purple lines that lie beneath both the green and blue lines indicate the level that would be set as a result of the combination of ducking task A and ducking task B. Notice how this line tracks the combined minimum values out of the two concurrent ducking tasks.

Don't be thrown off by the small vertical gap between the purple line and the green and blue lines. This gap is only provided to help distinguish between the different color lines and to make the diagram easier to view, but it should be interpreted that these lines that are shown so close together are directly on the same values for ducking scalar level.

Ducking and the Clip Extension

Every effort has been made in the design of the Music Object API, to design the different extensions in such a manner that they can interoperate with each other in useful and practical ways. One case in point is the Clip extension, which provides not only a very handy way of getting access to an individual Music Object instance that services the needs of a specific Music.Clip object instance, but also a handy way of accessing the entire list of Music.Clip object instances created in a page - regardless of how those instances were created.

Consequently, if you were creating a preview page using the Clip extension and you also wanted to have background music playing on that page, then you could quite easily use the Ducking extension to wire the Music Object instances for all the clips to the Music Object instance that will be playing the background music. The code to do this might look as follows...

for (var clipNo = 0; clipNo < Music.Clip.instances.length; clipNo++) {
   backgroundMO.addDuckingMasters (Music.Clip.instances [clipNo].musicObject);
}

In the above sample code snippet, it is assumed that the Clip extension and the Ducking extension have been sourced in, that all the Music.Clip object instances have been created, that the background music's Music Object instance has been created, etc.

What's New in the Latest Version

There is a dedicated version history for this extension, where you will be able to find out about the new features and possible issues with the most recent version. The version history for this extension is independent of the version history for the core Music Object API.

Getting This Extension

To get the "music-object-x-ducking.js" JavaScript file that implements this extension, simply right-click on this link (click-and-hold for Mac users). Then, from the menu that pops up, select the 'Save Link As...' or 'Save Target As...' option and save the file as "music-object-x-ducking.js" into an appropriate folder of the local copy of your Web site.

In case you have problems saving the file using the above link, the "music-object-x-ducking.js" file can also be found inside the documentation's "javascript" folder, along with the "music-object.js" file.

Dependencies

In order to use this extension, the following JavaScript file(s) must first be sourced in...

For more information on using extensions, consult the section About Music Object Extensions.

Reference

 Name   Short Description 
Instance Methods
addDuckingMasters Lets you add ducking masters for a Music Object instance.
addDuckingSlaves Lets you add ducking slaves for a Music Object instance.
getUsage Returns a string value, indicating the usage mode for the Music Object instance.
removeDuckingMasters Lets you remove ducking masters from a Music Object instance.
removeDuckingSlaves Lets you remove ducking slaves from a Music Object instance.
setUsage Lets you set the usage mode for the Music Object instance.
Static Methods
Music.addDuckingRelationships Lets you conveniently add many ducking slaves to many ducking masters in a single operation.
Music.removeDuckingRelationships Lets you conveniently remove many ducking slaves from many ducking masters in a single operation.
Static Properties
Music.duckingAttackTime An integer variable, specifying the default value that should be used for the AttackTimeMsINT parameter, if this parameter is not specified when setting up ducking relationships.
Music.duckingReleaseTime An integer variable, specifying the default value that should be used for the ReleaseTimeMsINT parameter, if this parameter is not specified when setting up ducking relationships.
Music.duckingSustainLevel An integer variable, specifying the default value that should be used for the SustainLevel0to100 parameter, if this parameter is not specified when setting up ducking relationships.

Instance Methods

 addDuckingMasters

 
 CATEGORY   Instance Method 
 MODULE   Music Object Extension - Ducking 
 Min. Player Version   1.3.0 
 File Types Supported   RMF, MIDI, WAV, AIFF, AU 
 

The addDuckingMasters instance method lets you add ducking masters for a Music Object instances.

SYNTAX    addDuckingMasters (
    DuckingMastersARRAYorOBJ ,
    AttackTimeMsINT ,
    SustainLevel0to100 ,
    ReleaseTimeMsINT
)

SPECIAL VALUES
VARIATIONS
NOTES
 addDuckingSlaves

 
 CATEGORY   Instance Method 
 MODULE   Music Object Extension - Ducking 
 Min. Player Version   1.3.0 
 File Types Supported   RMF, MIDI, WAV, AIFF, AU 
 

The addDuckingSlaves instance method lets you add ducking slaves for a Music Object instances.

SYNTAX    addDuckingSlaves (
    DuckingSlavesARRAYorOBJ ,
    AttackTimeMsINT ,
    SustainLevel0to100 ,
    ReleaseTimeMsINT
)

SPECIAL VALUES
VARIATIONS
NOTES
 getUsage

 
 CATEGORY   Instance Method 
 MODULE   Music Object Extension - Ducking 
 Min. Player Version   1.3.0 
 File Types Supported   RMF, MIDI, WAV, AIFF, AU 
 

The getUsage instance method returns a string value, indicating the usage mode for the Music Object instance

SYNTAX    getUsage ( )

RETURN VALUE    UsageSTR

NOTES
 removeDuckingMasters

 
 CATEGORY   Instance Method 
 MODULE   Music Object Extension - Ducking 
 Min. Player Version   1.3.0 
 File Types Supported   RMF, MIDI, WAV, AIFF, AU 
 

The removeDuckingMasters instance method lets you remove ducking masters from a Music Object instance.

SYNTAX    removeDuckingMasters ( DuckingMastersARRAYorOBJ )

SPECIAL VALUES
VARIATIONS
NOTES
 removeDuckingSlaves

 
 CATEGORY   Instance Method 
 MODULE   Music Object Extension - Ducking 
 Min. Player Version   1.3.0 
 File Types Supported   RMF, MIDI, WAV, AIFF, AU 
 

The removeDuckingSlaves instance method lets you remove ducking slaves from a Music Object instance.

SYNTAX    removeDuckingSlaves ( DuckingSlavesARRAYorOBJ )

SPECIAL VALUES
VARIATIONS
NOTES
 setUsage

 
 CATEGORY   Instance Method 
 MODULE   Music Object Extension - Ducking 
 Min. Player Version   1.3.0 
 File Types Supported   RMF, MIDI, WAV, AIFF, AU 
 

The setUsage instance method lets you set the usage mode for the Music Object instance.

SYNTAX    setUsage ( UsageSTR )

NOTES
Static Methods

 Music.addDuckingRelationships

 
 CATEGORY   Static Method 
 MODULE   Music Object Extension - Ducking 
 Min. Player Version   1.3.0 
 

The Music.addDuckingRelationships static method lets you conveniently add many ducking slaves to many ducking masters in a single operation.

SYNTAX    Music.addDuckingRelationships (
    DuckingMastersARRAYorOBJ ,
    DuckingSlavesARRAYorOBJ ,
    AttackTimeMsINT ,
    SustainLevel0to100 ,
    ReleaseTimeMsINT
)

SPECIAL VALUES
VARIATIONS
NOTES
 Music.removeDuckingRelationships

 
 CATEGORY   Static Method 
 MODULE   Music Object Extension - Ducking 
 Min. Player Version   1.3.0 
 

The Music.removeDuckingRelationships static method lets you conveniently remove many ducking slaves from many ducking masters in a single operation.

SYNTAX    Music.removeDuckingRelationships (
    DuckingMastersARRAYorOBJ ,
    DuckingSlavesARRAYorOBJ
)

SPECIAL VALUES
VARIATIONS
NOTES
Static Properties

 Music.duckingAttackTime

 
 CATEGORY   Static Property 
 MODULE   Music Object Extension - Ducking 
 Type   integer 
 Default Value   200 
 Access   read / write 
 

The Music.duckingAttackTime static property is an integer variable, specifying the default value that should be used for the AttackTimeMsINT parameter, if this parameter is not specified when setting up ducking relationships.

For more information, consult the section Setting Defaults for the Ducking Properties.

NOTES
 Music.duckingReleaseTime

 
 CATEGORY   Static Property 
 MODULE   Music Object Extension - Ducking 
 Type   integer 
 Default Value   0 
 Access   read / write 
 

The Music.duckingReleaseTime static property is an integer variable, specifying the default value that should be used for the ReleaseTimeMsINT parameter, if this parameter is not specified when setting up ducking relationships.

For more information, consult the section Setting Defaults for the Ducking Properties.

NOTES
 Music.duckingSustainLevel

 
 CATEGORY   Static Property 
 MODULE   Music Object Extension - Ducking 
 Type   integer 
 Default Value   1500 
 Access   read / write 
 

The Music.duckingSustainLevel static property is an integer variable, specifying the default value that should be used for the SustainLevel0to100 parameter, if this parameter is not specified when setting up ducking relationships.

For more information, consult the section Setting Defaults for the Ducking Properties.

NOTES